﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="kafn" uri="http://app.kanasinfo.com/jsp/taglib/functions"%>
<script>
//<![CDATA[
(function(){
	<c:forEach items="${catalogs}" var="catalog">
	if(appCenterResource["${catalog.root.id}"]) {
		$kdom.appendDojoProp("pane_${catalog.root.id}","title",appCenterResource["${catalog.root.id}"]);
	}
</c:forEach>
})();
//]]>
</script>
<span style="display:none">To solve IE7/8 script tag problem.</span>
<div id="accordionAppList" data-dojo-type="dijit/layout/AccordionContainer" style="height:100%"><!-- height:100% is used for IE7 -->
	<c:forEach items="${catalogs}" var="catalog" varStatus="statCata">
		<div id="pane_${catalog.root.id}" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="title:'${catalog.root.name}'">
			<script type="text/javascript">
			//<![CDATA[
				var catalogStore${statCata.count} = new dojo.store.Memory({
					data:[{id:"${catalog.root.id}",name:"${catalog.root.name}",type:"category"}
					//<c:forEach items="${catalog.categories}" var="category" >
					,{id:"${category.id}",name:(function(){return $ki18n(appCenterResource,"${category.id}",null,"${category.name}");})(),parent:"${category.superCategory.id}",type:"category"}
					//</c:forEach><c:forEach items="${catalog.modules}" var="module" >
					,{id:"m_${module.id}",mid:"${module.id}",name:(function(){return $ki18n(appCenterResource,"${module.id}",null,"${module.name}");})(),parent:"${module.superCategory.id}",type:"module",icon:"${module.iconClassS}"}
					//</c:forEach>
					],getChildren:function(object){
						return this.query({parent: object.id});
					}
				});
			//]]>
			</script>
			<div data-dojo-type="dijit/tree/ObjectStoreModel" data-dojo-id="catalogModel${statCata.count}"
			  data-dojo-props="store: catalogStore${statCata.count}, query: {id: '${catalog.root.id}'}"></div>
			<div data-dojo-type="dijit/Tree" id="catalogTree${statCata.count}" data-dojo-props="model: catalogModel${statCata.count}, showRoot: false,autoExpand:false,getIconClass:function(item,opened){return (!item || item.type=='category') ? (opened ? 'dijitFolderOpened' : 'dijitFolderClosed') : (item.icon?item.icon:'dijitLeaf');}" >
				<script type="dojo/event" data-dojo-event="onClick" data-dojo-args="item">
				if(item.mid)$ka.openModule(item.mid,null,{target:"moduleContainer",closable:true,i18nResource:appCenterResource});
				</script>
			</div>
		</div>
	</c:forEach>
</div>